package bar.dark.lee.setting.excel;

import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;

import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.Colour;
import jxl.format.VerticalAlignment;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;

import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.content.Intent;
import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import bar.dark.lee.BDConstents;
import bar.dark.lee.R;
import bar.dark.lee.SuperActivity;
import bar.dark.lee.common.BDUtil;
import bar.dark.lee.common.CalendarPickerDialog;
import bar.dark.lee.common.DBSQLite;
import bar.dark.lee.common.DBSQLite.ParseSelectData;
import bar.dark.lee.insert.InsertOutActivity;
import bar.dark.lee.select.SelectActivity;
import bar.dark.lee.select.SelectData;
import bar.dark.lee.select.SelectDayData;
import bar.dark.lee.select.search.SearchActivity;
import bar.dark.lee.setting.TipInfoActivity;
import bar.dark.lee.setting.TipsActivity;

public class ExcelActivity extends SuperActivity
{
	private DBSQLite sql;
	
	private String excelFolderName = "AccountBookExcel";
	private String excelFileName = "AccountBookExcel";
	
	private View startDateView;
	private TextView startDateTextView;
	
	private View endDateView;
	private TextView endDateTextView;
	
	private EditText folderNameEditText;
	private EditText fileNameEditText;
	
	private Button selectButton;
	
	private Button saveButton;
	
	private int toStartYear;
	private int toStartMonth;
	private int toStartDay;
	
	private int toEndYear;
	private int toEndMonth;
	private int toEndDay;
	
	private ArrayList<SelectDayData> monthList;
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		
		sql = DBSQLite.getInstance(this);
		
		setTitle("엑셀로 데이터 빼기");
		
		setContentView(R.layout.setting_excel_activity);
		setFindView();
		setOnClickListener();
		setData();
	}

	private void setFindView()
	{
		startDateView = findViewById(R.id.excelStartDate);
		startDateTextView = (TextView) findViewById(R.id.excelStartDateTextView);
		
		endDateView = findViewById(R.id.excelEndDate);
		endDateTextView = (TextView) findViewById(R.id.excelEndDateTextView);
		
		folderNameEditText = (EditText) findViewById(R.id.excelFolderNameEditText);
		fileNameEditText = (EditText) findViewById(R.id.excelFileNameEditText);
		
		selectButton = (Button) findViewById(R.id.excelSelectButton);
		
		saveButton = (Button) findViewById(R.id.excelButton);
	}
	
	private void setOnClickListener()
	{
		startDateView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
//				DatePickerDialog dialog = new DatePickerDialog(ExcelActivity.this, 
//						new OnDateSetListener()
//				{
//					@Override
//					public void onDateSet(DatePicker view, int year, int month,
//							int day)
//					{
//						int startDate = Integer.parseInt(BDUtil.getDateDB(year, month+1, day));
//						int endDate = Integer.parseInt(
//								BDUtil.getDateDB(toEndYear, toEndMonth+1, toEndDay));
//						
//						if (endDate < startDate)
//						{
//							BDUtil.showDialog(superContext, "알림", "시작날짜 보다 끝날짜가 클수 없습니다.");
//							return;
//						}
//						
//						toStartYear = year;
//						toStartMonth = month;
//						toStartDay = day;
//						startDateTextView.setText(BDUtil.getDate(year, month+1, day));
//					}
//				}, toStartYear, toStartMonth, toStartDay);
//				
//				dialog.show();
				
				CalendarPickerDialog cpd = new CalendarPickerDialog(superContext, new CalendarPickerDialog.ICalendarPickerDateSetListener() {
					@Override
					public void onDateSet(int year, int monthOfYear, int dayOfMonth) {
						
						int startDate = Integer.parseInt(BDUtil.getDateDB(year, monthOfYear+1, dayOfMonth));
						int endDate = Integer.parseInt(
								BDUtil.getDateDB(toEndYear, toEndMonth+1, toEndDay));
						
						if (endDate < startDate)
						{
							BDUtil.showDialog(superContext, "알림", "시작날짜 보다 끝날짜가 클수 없습니다.");
							return;
						}
						
						toStartYear = year;
						toStartMonth = monthOfYear;
						toStartDay = dayOfMonth;
						startDateTextView.setText(BDUtil.getDate(year, monthOfYear+1, dayOfMonth));
						
					}
				}, toStartYear, toStartMonth, toStartDay);
				
				cpd.show();
			}
		});
		
		endDateView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
//				DatePickerDialog dialog = new DatePickerDialog(ExcelActivity.this, 
//						new OnDateSetListener()
//				{
//					@Override
//					public void onDateSet(DatePicker view, int year, int month,
//							int day)
//					{
//						int startDate = Integer.parseInt(
//								BDUtil.getDateDB(toStartYear, toStartMonth+1, toStartDay));
//						int endDate = Integer.parseInt(BDUtil.getDateDB(year, month+1, day));
//						
//						if (endDate < startDate)
//						{
//							BDUtil.showDialog(superContext, "알림", "시작날짜 보다 끝날짜가 클수 없습니다.");
//							return;
//						}
//						
//						toEndYear = year;
//						toEndMonth = month;
//						toEndDay = day;
//						endDateTextView.setText(BDUtil.getDate(year, month+1, day));
//					}
//				}, toEndYear, toEndMonth, toEndDay);
//				
//				dialog.show();
				
				CalendarPickerDialog cpd = new CalendarPickerDialog(superContext, new CalendarPickerDialog.ICalendarPickerDateSetListener() {
					@Override
					public void onDateSet(int year, int monthOfYear, int dayOfMonth) {
						
						int startDate = Integer.parseInt(
								BDUtil.getDateDB(toStartYear, toStartMonth+1, toStartDay));
						int endDate = Integer.parseInt(BDUtil.getDateDB(year, monthOfYear+1, dayOfMonth));
						
						if (endDate < startDate)
						{
							BDUtil.showDialog(superContext, "알림", "시작날짜 보다 끝날짜가 클수 없습니다.");
							return;
						}
						
						toEndYear = year;
						toEndMonth = monthOfYear;
						toEndDay = dayOfMonth;
						endDateTextView.setText(BDUtil.getDate(year, monthOfYear+1, dayOfMonth));
						
					}
				}, toEndYear, toEndMonth, toEndDay);
				
				cpd.show();
			}
		});
		
		selectButton.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				Intent intent = new Intent(superContext, SelectActivity.class);
				intent.putExtra(SearchActivity.SEARCH_FLAG, true);
				intent.putExtra(SearchActivity.SEARCH_START_DATE,
						BDUtil.getDateDB(toStartYear, toStartMonth+1, toStartDay));
				intent.putExtra(SearchActivity.SEARCH_END_DATE,
						BDUtil.getDateDB(toEndYear, toEndMonth+1, toEndDay));
				startActivity(intent);
			}
		});
		
		saveButton.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				if (folderNameEditText.getText().toString().equals(""))
				{
					BDUtil.showDialog(superContext, "확인", "폴더명을 정확히 입력해주세요.");
					return;
				}
				
				if (fileNameEditText.getText().toString().equals(""))
				{
					BDUtil.showDialog(superContext, "확인", "파일명을 정확히 입력해주세요.");
					return;
				}
				
				new ShowDialog().execute(BDUtil.asyncFlag, 1);
			}
		});
	}
	
	private void setData()
	{
		Calendar cal = Calendar.getInstance();
		toStartYear = cal.get(Calendar.YEAR);
		toStartMonth = cal.get(Calendar.MONTH);
		toStartDay = cal.get(Calendar.DAY_OF_MONTH);
		
		toEndYear = cal.get(Calendar.YEAR);
		toEndMonth = cal.get(Calendar.MONTH);
		toEndDay = cal.get(Calendar.DAY_OF_MONTH);
		
		startDateTextView.setText(BDUtil.getDate(toStartYear, toStartMonth+1, toStartDay));
		endDateTextView.setText(BDUtil.getDate(toEndYear, toEndMonth+1, toEndDay));
		
		folderNameEditText.setText(excelFolderName);
		
		int year = cal.get(Calendar.YEAR);
		int month = cal.get(Calendar.MONTH) + 1;
		int day = cal.get(Calendar.DAY_OF_MONTH);
		String time = cal.get(Calendar.HOUR) + "" + cal.get(Calendar.MINUTE) + "" + cal.get(Calendar.SECOND);
		
		String date = BDUtil.getDate(year, month, day);
		
		date = date.replace(" ", "");
		
		String fileName = excelFileName + date + "_" + time;
		
		fileNameEditText.setText(fileName);
	}
	
	private void setExcelData()
	{
		monthList = new ArrayList<SelectDayData>();
		
		int count = 1;
		
		int dayCount = toEndYear - toStartYear;
		int monthCount = 0;
		
		if (dayCount > 0)
		{
			monthCount = ((toEndMonth + 1) + 12) - (toStartMonth + 1);
		}
		else
		{
			monthCount = (toEndMonth + 1) - (toStartMonth + 1);
		}
		
		count = count + monthCount;
		
		for (int i = 0; i < count; i++)
		{
			Calendar cal = Calendar.getInstance();
			cal.set(toStartYear, toStartMonth, toStartDay);
			
			for (int j = 0; j < i; j++)
			{
				cal.add(Calendar.MONTH, 1);
			}
			
			setListData(cal, i , count);
		}
	}

	private void setListData(Calendar cal, int i, int count)
	{
		String start = "";
		String end = "";
		
		int year = cal.get(Calendar.YEAR);
		final int month = cal.get(Calendar.MONTH);
		int day = cal.get(Calendar.DAY_OF_MONTH);
		
		if (i == 0)
		{
			if (i == count-1)
			{
				start = BDUtil.getDateDB(toStartYear, toStartMonth+1, toStartDay);
				end = BDUtil.getDateDB(toEndYear, toEndMonth+1, toEndDay);
			}
			else
			{
				start = BDUtil.getDateDB(year, month+1, toStartDay);
				
				end = BDUtil.getDateDB(year, month+1, 31);
			}
		}
		else if (i == count -1)
		{
			start = BDUtil.getDateDB(year, month+1, 01);
			end = BDUtil.getDateDB(year, month+1, toEndDay);
		}
		else
		{
			start = BDUtil.getDateDB(year, month+1, 01);
			end = BDUtil.getDateDB(year, month+1, 31);
		}
		
		String query = "SELECT * FROM in_out WHERE date >= "
						+ start + " and date <= " 
						+ end + " ORDER BY date ASC;";
		
		sql.selectMapTile(this, query, new ParseSelectData()
		{
			@Override
			public void resultData(Cursor c)
			{
				SelectDayData monthData = new SelectDayData();
				ArrayList<SelectData> list = monthData.getDayList();
				
				BigDecimal dayInMoney = BigDecimal.ZERO;
				BigDecimal dayOutMoney = BigDecimal.ZERO;
				BigDecimal dayPostMoney = BigDecimal.ZERO;
				
				int monthDate = 0;
				
				int id = c.getColumnIndex("id");
				int category = c.getColumnIndex("category");
				int memo = c.getColumnIndex("memo");
				int inmoney = c.getColumnIndex("inmoney");
				int outmoney = c.getColumnIndex("outmoney");
				int date = c.getColumnIndex("date");
				int moneykind = c.getColumnIndex("moneykind");
				int postmoneykind = c.getColumnIndex("postmoneykind");
				int postmoney = c.getColumnIndex("postmoney");
				int type = c.getColumnIndex("type");
				int linkid = c.getColumnIndex("linkid");
				int linktype = c.getColumnIndex("linktype");
				int deleteyn = c.getColumnIndex("deleteyn");
				
				c.moveToFirst();
				for (int j = 0; j < c.getCount(); j++)
				{
					SelectData data = new SelectData();
					data.setId(c.getInt(id) + "");
					data.setCategory(c.getString(category));
					data.setMemo(c.getString(memo));
					data.setInMoney(c.getString(inmoney));
					data.setOutMoney(c.getString(outmoney));
					data.setPostMoney(c.getString(postmoney));
					data.setDate(c.getInt(date) + "");
					data.setMoneyKind(c.getString(moneykind));
					data.setPostMoneyKind(c.getString(postmoneykind));
					data.setType(c.getInt(type) + "");
					data.setLinkId(c.getInt(linkid) + "");
					data.setLinktype(c.getInt(linktype) + "");
					data.setDeleteYn(c.getInt(deleteyn) + "");
					
					monthDate = c.getInt(date); 
					
					if (!c.getString(type).equals(BDConstents.INOUT_TYPE) 
							&& !c.getString(type).equals(BDConstents.OUTIN_TYPE)
							&& !c.getString(type).equals(BDConstents.MYBANK_INOUT_TYPE))
					{
						dayInMoney = dayInMoney.add(new BigDecimal(c.getString(inmoney)));
						dayOutMoney = dayOutMoney.add(new BigDecimal(c.getString(outmoney)));
						dayPostMoney = dayPostMoney.add(new BigDecimal(c.getString(postmoney)));
						
					}
					else
					{
						if (c.getString(linktype).equals("3"))
						{
							dayPostMoney = dayPostMoney.add(new BigDecimal(c.getString(postmoney)));
						}
						else if (c.getString(category).equals(BDConstents.CATEGORY_SUSUMONEY))
						{
							dayOutMoney = dayOutMoney.add(new BigDecimal(c.getString(outmoney)));
						}
					}
					
					list.add(data);
					
					c.moveToNext();
				}
				
				if (list.size() < 1)
				{
					return;
				}
				
				monthData.setDayInMoney(dayInMoney.toString());
				monthData.setDayOutMoney(dayOutMoney.toString());
				monthData.setDayPostMoney(dayPostMoney.toString());
				monthData.setToDay(monthDate + "");
				monthData.setDayList(list);
				monthList.add(monthData);
			}
		});
	}
	
	private boolean setFileData()
	{
		WritableWorkbook workbook = null;
		
		try
		{
			if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()))
			{
				return false;
			}
			
			String folderName = folderNameEditText.getText().toString();
			String fileName = fileNameEditText.getText().toString();
			
			File directory = new File(Environment.getExternalStorageDirectory() + "/" + folderName);
			
			if (!directory.exists())
			{
				directory.mkdir();
			}
			
			File file = new File(directory + "/" + fileName + ".xls");
			
			workbook = Workbook.createWorkbook(file); 
			
			for (int i = 0; i < monthList.size(); i++)
			{
				SelectDayData monthData = monthList.get(i);
				
				int [] arrDate = BDUtil.getDateSet(monthData.getToDay());
				
				String date = arrDate[0] + " - " + arrDate[1] + "월";
				
				WritableSheet sheet = workbook.createSheet(date, i);
				
				sheet.setColumnView(0, 20);
				sheet.setColumnView(1, 15);
				sheet.setColumnView(2, 15);
				sheet.setColumnView(3, 12);
				sheet.setColumnView(4, 20);
				sheet.setColumnView(5, 20);
				sheet.setColumnView(6, 20);
				sheet.setColumnView(7, 20);
				sheet.setColumnView(8, 40);
				
				WritableCellFormat titleFormat = new WritableCellFormat(); // 번호 셀 포멧 생성
			    WritableCellFormat dateFormat = new WritableCellFormat(); // 이름 셀 포멧 생성
			    WritableCellFormat dataFormat = new WritableCellFormat(); // 데이터 셀 포멧 생성
			    WritableCellFormat moneyFormat = new WritableCellFormat(); // 금액 셀 포멧 생성
			    
			    
			    titleFormat.setAlignment(Alignment.CENTRE); // 셀 가운데 정렬
			    titleFormat.setVerticalAlignment(VerticalAlignment.CENTRE); // 셀 수직 가운데 정렬
//			    titleFormat.setBorder(Border.ALL, BorderLineStyle.DASHED); // 보더와 보더라인스타일 설정
			    titleFormat.setBackground(Colour.ICE_BLUE); // 여름에 맞는 색깔 ? ^^
			  
			    dateFormat.setAlignment(Alignment.CENTRE); // 셀 가운데 정렬
			    dateFormat.setVerticalAlignment(VerticalAlignment.CENTRE); // 셀 수직 가운데 정렬
//			    nameFormat.setBorder(Border.BOTTOM, BorderLineStyle.HAIR); // 보더와 보더라인스타일 설정
			    dateFormat.setBackground(Colour.LIGHT_ORANGE); // 여름에 맞는 색깔 두번째 ? ^^
			    
			    dataFormat.setAlignment(Alignment.CENTRE); // 셀 가운데 정렬
			    dataFormat.setVerticalAlignment(VerticalAlignment.CENTRE); // 셀 수직 가운데 정렬
			    
			    moneyFormat.setAlignment(Alignment.RIGHT); // 셀 가운데 정렬
			    moneyFormat.setVerticalAlignment(VerticalAlignment.CENTRE); // 셀 수직 가운데 정렬

			    Label numberLabel1 = new Label(0, 0, "날짜", titleFormat);
			    sheet.addCell(numberLabel1); 
			    Label numberLabel2 = new Label(1, 0, "타입", titleFormat);
			    sheet.addCell(numberLabel2); 
			    Label numberLabel3 = new Label(2, 0, "이름", titleFormat);
			    sheet.addCell(numberLabel3); 
			    Label numberLabel4 = new Label(3, 0, "종류", titleFormat);
			    sheet.addCell(numberLabel4); 
			    Label numberLabel5 = new Label(4, 0, "카테고리", titleFormat);
			    sheet.addCell(numberLabel5); 
			    Label numberLabel6 = new Label(5, 0, "수입", titleFormat);
			    sheet.addCell(numberLabel6); 
			    Label numberLabel7 = new Label(6, 0, "지출", titleFormat);
			    sheet.addCell(numberLabel7); 
			    Label numberLabel8 = new Label(7, 0, "카드대금", titleFormat);
			    sheet.addCell(numberLabel8); 
			    Label numberLabel9 = new Label(8, 0, "내용", titleFormat);
			    sheet.addCell(numberLabel9); 
			    
			    ArrayList<SelectData> list = monthData.getDayList();
			    
			    for (int j = 0; j < list.size(); j++)
				{
			    	SelectData data = list.get(j);
			    	
			    	Label nameLabel = new Label(0, j+1, BDUtil.getDateButton(data.getDate()), dateFormat);
			    	sheet.addCell(nameLabel); 
			    	
				    Label dataLabel1 = new Label(1, j+1, getType(data.getType()), dataFormat);
				    sheet.addCell(dataLabel1); 
				    Label dataLabel2 = new Label(2, j+1, data.getMoneyKind(), dataFormat);
				    sheet.addCell(dataLabel2); 
				    Label dataLabel3 = new Label(3, j+1, getType(data.getLinktype()), dataFormat);
				    sheet.addCell(dataLabel3); 
				    Label dataLabel4 = new Label(4, j+1, data.getCategory(), dataFormat);
				    sheet.addCell(dataLabel4); 
				    Label dataLabel5 = new Label(5, j+1, BDUtil.getWon(data.getInMoney()), moneyFormat);
				    sheet.addCell(dataLabel5); 
				    Label dataLabel6 = new Label(6, j+1, BDUtil.getWon(data.getOutMoney()), moneyFormat);
				    sheet.addCell(dataLabel6); 
				    Label dataLabel7 = new Label(7, j+1, BDUtil.getWon(data.getPostMoney()), moneyFormat);
				    sheet.addCell(dataLabel7); 
				    Label dataLabel8 = new Label(8, j+1, data.getMemo(), dataFormat);
				    sheet.addCell(dataLabel8);
				}
			    
			    Label dataLabel1 = new Label(5, list.size()+2, "이달수입", dataFormat);
			    sheet.addCell(dataLabel1); 
			    Label dataLabel2 = new Label(6, list.size()+2, "이달지출", dataFormat);
			    sheet.addCell(dataLabel2); 
			    Label dataLabel3 = new Label(7, list.size()+2, "이달카드대금", dataFormat);
			    sheet.addCell(dataLabel3);
			    
			    Label dataLabel4 = new Label(5, list.size()+3, 
			    		BDUtil.getWon(monthData.getDayInMoney()), moneyFormat);
			    sheet.addCell(dataLabel4); 
			    Label dataLabel5 = new Label(6, list.size()+3, 
			    		BDUtil.getWon(monthData.getDayOutMoney()), moneyFormat);
			    sheet.addCell(dataLabel5); 
			    Label dataLabel6 = new Label(7, list.size()+3, 
			    		BDUtil.getWon(monthData.getDayPostMoney()), moneyFormat);
			    sheet.addCell(dataLabel6); 
			}
			
			workbook.write(); // 준비된 정보를 엑셀 포멧에 맞게 작성
		} catch (Exception e)
		{
			e.printStackTrace();
			return false;
		} finally {
			try
			{
				if (workbook != null)
				{
					workbook.close();
				}
			} catch (Exception e)
			{
				e.printStackTrace();
				return false;
			}
		}
		
		return true;
	}
	
	private String getType(String type)
	{
		String name = "";
		
		if (type.equals(BDConstents.REAL_TYPE))
		{
			name = BDConstents.REAL_MONEY;
		}
		else if (type.equals(BDConstents.BANK_TYPE))
		{
			name = BDConstents.BANK_MONEY;
		}
		else if (type.equals(BDConstents.CHECK_TYPE))
		{
			name = BDConstents.CHECK_CARD;
		}
		else if (type.equals(BDConstents.CREDIT_TYPE))
		{
			name = BDConstents.CREDIT_CARD;
		}
		else if (type.equals(BDConstents.INOUT_TYPE))
		{
			name = BDConstents.BANK_TO_REAL;
		}
		else if (type.equals(BDConstents.FAN_TYPE))
		{
			name = BDConstents.FAN_MONEY;
		}
		else if (type.equals(BDConstents.OUTIN_TYPE))
		{
			name = BDConstents.REAL_TO_BANK;
		}
		else if (type.equals(BDConstents.MYBANK_INOUT_TYPE))
		{
			name = BDConstents.MYBANK_INOUT;
		}
		return name;
	}

	/**
	 * 다이얼로그 뛰우기 
	 */
	private class ShowDialog extends AsyncTask<Integer, Integer, Integer>{
		ProgressDialog dialog = null;
		@Override
		protected void onPreExecute() {
			super.onPreExecute();
			if (BDUtil.btnEnable)
			{
				BDUtil.btnEnable = false;
				BDUtil.asyncFlag = -1;
				
				dialog = new ProgressDialog(ExcelActivity.this);
				dialog.setCancelable(false);
				dialog.setMessage("Loading...");
				dialog.show();
			}
		}
		
		@Override
		protected Integer doInBackground(Integer... arg0) {
			if (arg0[0] == 0) 
			{
				if (arg0[1] == 1)
				{
					setExcelData();
					
					if (monthList.size() < 1)
					{
						return 3;
					}
					
					if (!setFileData())
					{
						return 2;
					}
					
					return 1;
				}
			}
			else
			{
				return 0;
			}
			
			return null;
		}
		
		@Override
		protected void onPostExecute(Integer result) {
			super.onPostExecute(result);
			
			if (dialog != null) 
			{
				dialog.dismiss();
			}
			
			if (result == 1)
			{
				BDUtil.showDialogFinish(ExcelActivity.this, "확인", "엑셀파일이 생겼습니다. SD카드에서 확인해 주세요.");
			}
			else if (result == 2)
			{
				BDUtil.showDialog(ExcelActivity.this, "확인", "파일을 저장하는 중 에러가 생겼습니다. 다시 시도해주세요. 그래도 안되면 개발자한데 메일 주세요 ㅜ.ㅜ;");
				return;
			}
			else if (result == 3)
			{
				BDUtil.showDialog(ExcelActivity.this, "확인", "기간 사이에 데이터가 하나도 없습니다. 기간을 다시 설정후 저장해주세요.");
				return;
			}
			
		}
	}
	
	@Override
	protected void tipButton()
	{
		Intent intent = new Intent(this, TipInfoActivity.class);
		intent.putExtra(TipsActivity.TIP_REQUEST_KEY, TipsActivity.TIP_EXCEL);
		startActivity(intent);
	}
}
